/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.unipar.cursoweb.service;


import br.com.unipar.cursoweb.modelo.Cliente;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

/**
 * @author Thiago Marques
 */
@Service("clienteService")
public class ClienteServiceImpl
        extends GenericServiceImpl<Cliente>
        implements ClienteService {


    @Override
    public List<Cliente> consultar(String nome) {
        Criteria crit = ((Session) entityManager.getDelegate()).createCriteria(Cliente.class);
        if (nome != null) {
            crit.add(Restrictions.ilike("nome",
                    nome, MatchMode.ANYWHERE));
        }
        return crit.list();
    }
}
